const fs = require('fs');
const path = require('path');

//重新命名模块
var rename = function(oringinalName, newName) {
    return fs.rename(oringinalName, newName, function(err, data) {
        if (err) {
            console.log('失败');
        }else {
            console.log('成功');
        }
    });
    // console.log('hello');
}

//path解析模块
// var ult = "/Users/liyao/Documents/Nodejs/Study/first_framework/view/test_upload.html";
// var pathResult = path.parse(ult);
// console.log(pathResult);
// { root: '/',
//   dir: '/Users/liyao/Documents/Nodejs/Study/first_framework/view',
//   base: 'test_upload.html',
//   ext: '.html',
//   name: 'test_upload' }

// fs.rename('renameTest.txt', 'newName.txt', function(error, data) {
//     console.log(error);
// });

exports.rename = rename;